﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="vlaev_kod_vastus_laevaandmed", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(VlaevKodVastusLaevaandmed))]
    public class VlaevKodVastusLaevaandmedSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IVlaevKodVastusLaevaandmed clazz;
        
        public VlaevKodVastusLaevaandmedSerializer(IVlaevKodVastusLaevaandmed clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("laeva_regnr");
            if (clazz.LaevaRegnr!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.LaevaRegnr))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : LaevaRegnr");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("laeva_tahis");
            if (clazz.LaevaTahis!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.LaevaTahis))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : LaevaTahis");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("ehitusaasta");
            if (clazz.Ehitusaasta!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Ehitusaasta))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Ehitusaasta");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("regt");
            if (clazz.Regt!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Regt))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Regt");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("regt_kuup");
            if (clazz.RegtKuup!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.RegtKuup))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : RegtKuup");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("kehtiv_kuni");
            if (clazz.KehtivKuni!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KehtivKuni))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : KehtivKuni");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("liik_nm");
            if (clazz.LiikNm!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.LiikNm))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : LiikNm");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("tyyp_nm");
            if (clazz.TyypNm!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.TyypNm))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : TyypNm");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("kateg_nm");
            if (clazz.KategNm!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KategNm))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : KategNm");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mark");
            if (clazz.Mark!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Mark))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Mark");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mudel");
            if (clazz.Mudel!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Mudel))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Mudel");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("material_nm");
            if (clazz.MaterialNm!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MaterialNm))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : MaterialNm");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pikkus");
            if (clazz.Pikkus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Pikkus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Pikkus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("lubatud");
            if (clazz.Lubatud!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Lubatud))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Lubatud");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("omanik");
            if (clazz.Omanik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Omanik))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Omanik");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("omanik2");
            if (clazz.Omanik2!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Omanik2))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Omanik2");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("omanik_type");
            if (clazz.OmanikType!=null) {
                Writer.WriteTypeAttribute("http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", "t_omanik");
                Writer.WriteString(clazz.OmanikType.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OmanikType");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("vastutav");
            if (clazz.Vastutav!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Vastutav))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Vastutav");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("vastutav2");
            if (clazz.Vastutav2!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Vastutav2))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Vastutav2");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("olek_nm");
            if (clazz.OlekNm!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OlekNm))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OlekNm");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("piirangud");
            if (clazz.Piirangud!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Piirangud))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Piirangud");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("isikud");
            if (clazz.Isikud!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikud))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikud");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "laeva_regnr")) {
                goto laeva_regnr;
            }
            else {
                if ((Reader.LocalName == "laeva_tahis")) {
                    goto laeva_tahis;
                }
                else {
                    if ((Reader.LocalName == "ehitusaasta")) {
                        goto ehitusaasta;
                    }
                    else {
                        if ((Reader.LocalName == "regt")) {
                            goto regt;
                        }
                        else {
                            if ((Reader.LocalName == "regt_kuup")) {
                                goto regt_kuup;
                            }
                            else {
                                if ((Reader.LocalName == "kehtiv_kuni")) {
                                    goto kehtiv_kuni;
                                }
                                else {
                                    if ((Reader.LocalName == "liik_nm")) {
                                        goto liik_nm;
                                    }
                                    else {
                                        if ((Reader.LocalName == "tyyp_nm")) {
                                            goto tyyp_nm;
                                        }
                                        else {
                                            if ((Reader.LocalName == "kateg_nm")) {
                                                goto kateg_nm;
                                            }
                                            else {
                                                if ((Reader.LocalName == "mark")) {
                                                    goto mark;
                                                }
                                                else {
                                                    if ((Reader.LocalName == "mudel")) {
                                                        goto mudel;
                                                    }
                                                    else {
                                                        if ((Reader.LocalName == "material_nm")) {
                                                            goto material_nm;
                                                        }
                                                        else {
                                                            if ((Reader.LocalName == "pikkus")) {
                                                                goto pikkus;
                                                            }
                                                            else {
                                                                if ((Reader.LocalName == "lubatud")) {
                                                                    goto lubatud;
                                                                }
                                                                else {
                                                                    if ((Reader.LocalName == "omanik")) {
                                                                        goto omanik;
                                                                    }
                                                                    else {
                                                                        if ((Reader.LocalName == "omanik2")) {
                                                                            goto omanik2;
                                                                        }
                                                                        else {
                                                                            if ((Reader.LocalName == "omanik_type")) {
                                                                                goto omanik_type;
                                                                            }
                                                                            else {
                                                                                if ((Reader.LocalName == "vastutav")) {
                                                                                    goto vastutav;
                                                                                }
                                                                                else {
                                                                                    if ((Reader.LocalName == "vastutav2")) {
                                                                                        goto vastutav2;
                                                                                    }
                                                                                    else {
                                                                                        if ((Reader.LocalName == "olek_nm")) {
                                                                                            goto olek_nm;
                                                                                        }
                                                                                        else {
                                                                                            if ((Reader.LocalName == "piirangud")) {
                                                                                                goto piirangud;
                                                                                            }
                                                                                            else {
                                                                                                if ((Reader.LocalName == "isikud")) {
                                                                                                    goto isikud;
                                                                                                }
                                                                                                else {
                                                                                                    return;
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        laeva_regnr:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>laeva_regnr");
            }
            clazz.LaevaRegnr = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("laeva_regnr")).Value;
            goto START;
        laeva_tahis:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>laeva_tahis");
            }
            clazz.LaevaTahis = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("laeva_tahis")).Value;
            goto START;
        ehitusaasta:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>ehitusaasta");
            }
            clazz.Ehitusaasta = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ehitusaasta")).Value;
            goto START;
        regt:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>regt");
            }
            clazz.Regt = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("regt")).Value;
            goto START;
        regt_kuup:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>regt_kuup");
            }
            clazz.RegtKuup = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("regt_kuup")).Value;
            goto START;
        kehtiv_kuni:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>kehtiv_kuni");
            }
            clazz.KehtivKuni = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kehtiv_kuni")).Value;
            goto START;
        liik_nm:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>liik_nm");
            }
            clazz.LiikNm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("liik_nm")).Value;
            goto START;
        tyyp_nm:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>tyyp_nm");
            }
            clazz.TyypNm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tyyp_nm")).Value;
            goto START;
        kateg_nm:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>kateg_nm");
            }
            clazz.KategNm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kateg_nm")).Value;
            goto START;
        mark:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>mark");
            }
            clazz.Mark = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("mark")).Value;
            goto START;
        mudel:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>mudel");
            }
            clazz.Mudel = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("mudel")).Value;
            goto START;
        material_nm:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>material_nm");
            }
            clazz.MaterialNm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("material_nm")).Value;
            goto START;
        pikkus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>pikkus");
            }
            clazz.Pikkus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pikkus")).Value;
            goto START;
        lubatud:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>lubatud");
            }
            clazz.Lubatud = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("lubatud")).Value;
            goto START;
        omanik:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>omanik");
            }
            clazz.Omanik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("omanik")).Value;
            goto START;
        omanik2:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>omanik2");
            }
            clazz.Omanik2 = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("omanik2")).Value;
            goto START;
        omanik_type:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>omanik_type");
            }
            clazz.OmanikType = new global::Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister.TOmanik(Reader.ReadElementString("omanik_type"));
            goto START;
        vastutav:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>vastutav");
            }
            clazz.Vastutav = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("vastutav")).Value;
            goto START;
        vastutav2:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>vastutav2");
            }
            clazz.Vastutav2 = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("vastutav2")).Value;
            goto START;
        olek_nm:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>olek_nm");
            }
            clazz.OlekNm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("olek_nm")).Value;
            goto START;
        piirangud:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>piirangud");
            }
            clazz.Piirangud = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("piirangud")).Value;
            goto START;
        isikud:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>vlaev_kod_vastus_laevaandmed>isikud");
            }
            clazz.Isikud = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikud")).Value;
            goto START;
        }
    }
}
